let createNewPromise = (url,params,promiseResolve)=>{
	return new Promise(() => {
		getApp().globalData.vxios.get(url,params)
			.then((res) =>{
				if(res.data.code === 200){
					promiseResolve(res.data.data)
				}
			})
			.catch((err) =>{
				console.log(err);
			})
	})
}

let putStatus = (url)=>{
	let promiseTemp = null;
	let promiseResolve = null;

	async function fun(){
	    promiseTemp = new Promise(resolve => promiseResolve = resolve); 
		new Promise(() => {
			getApp().globalData.vxios.put(url)
				.then((res) =>{
					promiseResolve(res.data.msg)
				})
				.catch((err) =>{
					console.log(err);
				})
		})
		let courses_list = await promiseTemp;
		return courses_list;
	}
	return fun()
}

//设置当前章节状态  sectionId章节id newStatus章节状态{0：未开始 1：已完成 2：学习中}
const setSectionStatus = (sectionId,newStatus)=>{
	console.log(1111111);
	console.log(getApp().globalData.vxios.defaults.header);	
	let url = getApp().globalData.baseUrl + "course/section/status?"
		+"status="+newStatus
		+"&sectionId="+sectionId;
	console.log(url);	
	return putStatus(url);
}

export default{
	setSectionStatus
}